package com.zndroid.utils.impl;

import android.content.Context;

import androidx.annotation.RawRes;


import java.io.BufferedReader;
import java.io.InputStreamReader;

@SuppressWarnings("unused")
public class RawUtil {
    public String readFromRaw(Context context, @RawRes int rawId) {
        try {
            InputStreamReader inputReader = new InputStreamReader(context.getResources().openRawResource(rawId));
            BufferedReader bufReader = new BufferedReader(inputReader);
            String line;
            StringBuilder result = new StringBuilder();
            while ((line = bufReader.readLine()) != null) {
                result.append(line);
            }
            return result.toString();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "";
    }
}
